# _*_ coding: utf-8 _*_
# @Time : 2024-01-19 21:48
# @Author : wf

import urllib.request
import http.client


url = 'https://dianying.taobao.com/cityAction.json?activityId&_ksTS=1705672187955_116&jsoncallback=jsonp117&action=cityAction&n_s=new&event_submit_doGetAllRegion=true'

headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0',
    'Cookie': 't=4834ffcbd47ddaceddecb4b8654d30d3; cookie2=18a1cf55ed76d16413cf021ccd0f6464; v=0; _tb_token_=e373b111dde16; cna=cQzOGX8RfUQCAd3ajJ/aqOO5; xlly_s=1; tfstk=elEB3m9zTBAINrYH166aCaiHADn5QWs2NLM8n8KeeDnKFgNz_pyUUkzse7PGE9mUebN7_fVSr9crwbNzeyWN0iy3K0m-NsSV0OhbhQ52BcWO_Jmo21Jw2ZSbKS5FTgSXT_ddyUwGIULW220p28v2ELqsB_cYdFtmplHBOb2I1_17f10IMJh62gPy0jGerU9so3MsgO66rUXgV6DYU6f7x2Hid1B1CBAjJADsgO66rU0KIvZACOOHG; isg=BL29SwonhHYUQiAakMcm9Xg3zBm3WvGsXPDDkn8BC5RDttzoR6vSfSFoYOrwMwlk',
    'Referer': 'https://dianying.taobao.com/',
}

req = urllib.request.Request(url, headers=headers)

response: http.client.HTTPResponse = urllib.request.urlopen(req)
content = response.read().decode('utf-8')

content = content.split('(')[1].split(')')[0]
# print(content)

with open('taopiaopiao.json', 'w+', encoding='utf-8') as fp:
    fp.write(content)

